<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2022/5/7
  Time: 10:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>

</head>

<body>
<div class="x-nav">
			<span class="layui-breadcrumb">
				<a href="">首页</a>
				<a href="">演示</a>
				<a>
					<cite>导航元素</cite></a>
			</span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">

    <xblock>
        <button class="layui-btn" onclick="x_admin_show('添加文件','/myFilePage/myFileAdd',600,400)"><i
                class="layui-icon"></i>新增文件</button>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>ID</th>
            <th>文件名</th>
            <th>文件地址</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="tb">


        </tbody>
    </table>

</body>
    <script>
        //定义加载所有数据的方法
        function loadData() {

            $.ajax({
                url:"/myFileAjax/list",
                type:"get",
                success:function (rs) {
                    console.log(rs);
                    if(rs.success){
                        var html = "";

                        for(var i=0;i<rs.data.length;i++){
                            html+="<tr>" +
                                "<td>"+rs.data[i].fileId+"</td>" +
                                "<td>"+rs.data[i].fileName+"</td>" +
                                "<td>"+rs.data[i].fileUrl+"</td>" +
                                "<td class=\"td-manage\">"+
                                "<a title=\"文件下载\" onclick=\"downLoad(this)\" href=\"javascript:;\">"+
                                "文件下载</a>"+

                                "</td>"+
                                "</tr>"

                        }
                        //显示在表格中
                        $("#tb").html(html);
                    }

                }
            })

        }


        //文档加载事件
        $(function () {
            //运行加载数据
            loadData();
        })
        //文件下载
        function downLoad(obj){
            //获取选中行文件名
            var fileName = $(obj).parent().parent().find("td").eq(1).text();
            console.log(fileName);
            //访问文件下载地址
            window.location.href="/file/downLoad?fileName="+fileName;

        }

    </script>



</html>

